<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://xmlns.jcp.org/jsf/core">
    <!--开始 文章详情-->
    <c:choose>
        <c:when test="#{articleBean.post!=null}">
            <div class="col-sm-8 blog-main">
                <div class="blog-post">
                    <h2 class="blog-post-title">${articleBean.post.title}</h2>
                    <div class="blog-post-meta well small" style="padding: 2%;">
                        作者：<span class="blog-post-publish-author">#{articleBean.post.author.username}</span> |
                        发表于：<span class="blog-post-publish-date">#{articleBean.post.publishDate}</span> |
                        分类：<span class="blog-post-publish-category">#{articleBean.post.category.name}</span> |
                        +#{articleBean.post.hint} 浏览
                    </div>
                    <div class="blog-post-content">
                        <h:outputText escape="false" value="#{articleBean.post.content}"/>
                    </div><!-- /.blog-post-content -->
                </div><!-- /.blog-post -->

                <h:form id="post-like">
                    <div class="blog-post-meta blog-post-meta-like well small" style="padding: 2%;">
                        <c:choose>
                            <c:when test="#{userBean.currentUser != null}">
                                <input type="hidden" name="id" value="#{articleBean.post.id}"/>
                                <c:choose>
                                    <c:when test="#{userBean.liked(articleBean.post)}">
                                        <h:commandLink value="取消收藏" action="#{userBean.like(articleBean.post)}">
                                            <f:ajax render="post-like"/>
                                        </h:commandLink>
                                    </c:when>
                                    <c:otherwise>
                                        <h:commandLink value="收藏本文" action="#{userBean.like(articleBean.post)}">
                                            <f:ajax render="post-like"/>
                                        </h:commandLink>
                                    </c:otherwise>
                                </c:choose>
                            </c:when>
                            <c:otherwise>
                                <input type="hidden" name="returnUrl"
                                       value="${request.requestURI}?${request.queryString}"/>
                                <h:commandLink action="#{articleBean.toLogin}" value="登录"/>后可收藏本文
                            </c:otherwise>
                        </c:choose>
                    </div>
                </h:form>

                <nav>
                    <ul class="pager">
                        <c:choose>
                            <c:when test="#{articleBean.prevId gt 0}">
                                <li>
                                    <h:link value="上一篇" outcome="article">
                                        <f:param name="id" value="#{articleBean.prevId}"/>
                                    </h:link>
                                </li>
                            </c:when>
                            <c:otherwise>
                                <li><span>上一篇</span></li>
                            </c:otherwise>
                        </c:choose>
                        <c:choose>
                            <c:when test="#{articleBean.nextId gt 0}">
                                <li>
                                    <h:link value="下一篇" outcome="article">
                                        <f:param name="id" value="#{articleBean.nextId}"/>
                                    </h:link>
                                </li>
                            </c:when>
                            <c:otherwise>
                                <li><span>下一篇</span></li>
                            </c:otherwise>
                        </c:choose>
                    </ul>
                </nav>
                <div class="blog-comment">
                    <ui:include src="comments.xhtml"/>
                </div>
            </div><!-- /.blog-main -->
        </c:when>
        <c:otherwise>
            找不到文章
        </c:otherwise>
    </c:choose>
    <!--结束 文章详情-->
</ui:composition>